<%@ page isELIgnored="false" language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>


<script type="text/javascript">
    $(function(){
       $("#powerTable").datagrid({
           fit:"true",
           pagination:"true",
           url:"${pageContext.request.contextPath}/Role/selectAllRole.do",
           columns:[[
               {field:'roleId',title:'序号',width:100},
               {field:'roleName',title:'角色名',width:100},
               {field:'beizhu',title:'备注',width:100,
                    formatter: function(value,row,index){
                        if (row.roleId==1){
                            return "管理员";
                        } if(row.roleId==2) {
                            return "超级管理员";
                        }
                    }
               },
               {field:'xuanxiang',title:'操作',width:100,
                   formatter: function(value,row,index){
                      return "<image src='${pageContext.request.contextPath}/img/quanxian/2019-04-22_091710.png' onclick='doDelatePower("+row.roleId+")'/>&nbsp;" +
                          "<image src='${pageContext.request.contextPath}/img/quanxian/2019-04-22_091657.png' onclick='doDelatePower("+row.roleId+")'/>"
                   }
               }
           ]],
           onDblClickRow: function (index, rowDate) {
                console.log("011111");
                $("#userRole").val(rowDate.roleName);
                var role;
                if (rowDate.roleId==1){
                   $("#userRoleBeizhu").val("管理员");
                   role=rowDate.roleName;
                } if(rowDate.roleId==2) {
                   $("#userRoleBeizhu").val("超级管理员");
                   role=rowDate.roleName;
                }


                $('#Powerwin').window({
                    closed:false
                });
               $('#cmfzPowertree').treegrid({
                   fit:true,
                   url:'${pageContext.request.contextPath}/Power/selectPowerTree.do?roleName='+role,
                   idField:'id',
                   treeField:'name',
                   method: "get",
                   checkbox:true,
                   onDblClickCell:function (field, row) {
                       console.log(row);
                   },
                   columns:[[
                       {field: 'id',title: '权限编号',  width: 200},
                       {field: 'name', title: '子级权限编号', width: 400},

                   ]],
               });

           },
       });
    });

    function doDelatePower(roleId){
        console.log(roleId+"+++++");
    }
    function doUpdatePower(roleId){
        console.log(roleId+"-----");
    }
</script>




<table id="powerTable" class="easyui-datagrid" style="width:400px;height:250px">

</table>

<%--<ul id="cmfzPowertree"></ul>--%>
<div id="Powerwin" class="easyui-window" title="My Window" style="width:600px;height:400px"
     data-options="iconCls:'icon-save',modal:true,closed:true">

    角色名：<input type="text" id="userRole" ></br>
    备注：<input type="text" id="userRoleBeizhu" />
    <table id="cmfzPowertree" style="width:600px;height:400px"></table>
</div>


